<!DOCTYPE html>
<ui:composition template="/template/layout.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui">

	<f:metadata>
	
		<f:viewAction action="#{pessoaController.iniciarDados()}" />
		
	</f:metadata>
	
	<ui:define name="titulo">Consulta de Pessoas</ui:define>
	
	<ui:define name="corpo">
	
		<h1>Consulta de Pessoas</h1>
		
		<h:form id="frm">

			<p:dataTable value="#{pessoaController.pessoaForm.listagemPessoa}" var="item" border="1" cellspacing="0" cellpadding="2" paginator="true" rows="40" paginatorPosition="bottom"
			lazy="true"
			paginatorTemplate=" {CurrentPageReport} {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
		    currentPageReportTemplate="#{message['label.mostrando']} {startRecord} #{message['label.ate']} {endRecord} #{message['label.de']} {totalRecords} #{message['label.encontrados']}">

				<p:column headerText="ID" sortBy="#{item.id}">
					<h:outputText value="#{item.id}" />
				</p:column>

				<p:column headerText="Nome" sortBy="#{item.nome}">
					<h:outputText value="#{item.nome}" />
				</p:column>

				<p:column headerText="Ações" width="100" style="text-align: center;">
					<p:button icon="ui-icon-pencil" title="Editar" outcome="/paginas/pessoas/cadastroPessoa">
						<f:param name="id" value="#{item.id}" />
					</p:button>

					<p:commandButton icon="ui-icon-trash" title="Excluir" process="@this" update="@form" action="#{pessoaController.excluir()}">
						<f:setPropertyActionListener value="#{item}" target="#{pessoaController.pessoaForm.consulta}" />
					</p:commandButton>

				</p:column>

			</p:dataTable>

		</h:form>
	</ui:define>
</ui:composition>